<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Setup extends CI_Controller {
    
    public function __construct()
    {
        parent::__construct();

        $this->load->dbforge();
    }
    public function index()
    {
        // todo: create a basic interface
    }
    
    public function sourcecode()
    {
        // set table name
        $tablename = 'tblsourcecode';
        
        // set table columns
        $fields = array(
            'source_id' => array(
                'type' => 'INT',
                'constraint' => 5,
                'unsigned' => TRUE,
                'auto_increment' => TRUE
             ),
            'source_code' => array(
                'type' => 'TEXT'
             ),
             'source_unique' => array(
                'type' => 'VARCHAR',
                'constraint' => 5
             ),
             'source_created' => array(
                'type' => 'TIMESTAMP'
             )             
        );
        
        $this->dbforge->add_key('source_id', TRUE);
        
       echo 'Dropping table [' . $tablename . '] if exists...';
        if($this->dbforge->drop_table($tablename))
        {
            echo 'DONE';
        }
        echo '<br />';
       
        $this->dbforge->add_field($fields);
  
        echo 'Creating table ['. $tablename .'] if not exists...';
        if($this->dbforge->create_table($tablename, TRUE))
        {
            echo 'DONE';
        }
         
    }
    
    
   
}

/* End of file setup.php */
/* Location: ./application/controllers/setup.php */